From: Jasper St. Pierre Date: Tue, 28 Jan 2014 17:06:11 +0000 (-0500) Subject: appDisplay: Support the 'categories' key for app folders X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~2865 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=bb8fa61cb4696f2248a6cf65f3a64e00d342d828;p=gnome-shell.git appDisplay: Support the 'categories' key for app folders https://bugzilla.gnome.org/show_bug.cgi?id=723179 --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 165fa59f2..ec71ad00a 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -61,6 +61,13 @@ function _isTerminal(app) { return categories.indexOf('TerminalEmulator') > -1; } +function _listsIntersect(a, b) { + for (let itemA of a) + if (b.indexOf(itemA) >= 0) + return true; + return false; +} + function _getFolderName(folder) { let name = folder.get_string('name'); @@ -1069,9 +1076,7 @@ const FolderIcon = new Lang.Class({ this.view.removeAll(); let appSys = Shell.AppSystem.get_default(); - - let folderApps = this._folder.get_strv('apps'); - folderApps.forEach(Lang.bind(this, function(appId) { + let addAppId = (function addAppId(appId) { let app = appSys.lookup_app(appId); if (!app) return; @@ -1081,7 +1086,20 @@ const FolderIcon = new Lang.Class({ let icon = new AppIcon(app); this.view.addItem(icon); - })); + }).bind(this); + + let folderApps = this._folder.get_strv('apps'); + folderApps.forEach(addAppId); + + let folderCategories = this._folder.get_strv('categories'); + Gio.AppInfo.get_all().forEach(function(appInfo) { + let appCategories = _getCategories(appInfo); + if (!_listsIntersect(folderCategories, appCategories)) + return; + + addAppId(appInfo.get_id()); + }); + this.view.loadGrid(); this.emit('apps-changed'); },